/*
 * @Descripttion: 
 * @Author: zhangchong zc16607@gmail.com
 * @Date: 2023-02-27 16:08:44
 * @LastEditors: zhangchong zc16607@gmail.com
 * @LastEditTime: 2023-02-28 17:27:34
 */
const mongoose = require('mongoose')

// 模板校验规则
const tableSchema = new mongoose.Schema(
  {
    name: { type: String, required: true },
    prices: { type: Array, required: true },
    createdAt: { type: Date, required: true, default: new Date().toLocaleString('zh-cn', { hour12: false }) },
    pubDate: { type: String }
  }
)

tableSchema.index({ name: 1, pubDate: 1 }, { unique: true }) // 设置组合唯一键

// 创建模板 执行之后会自动在mongodb中创建相应的模板
const exampleModel = mongoose.model('exampletable', tableSchema)


export default exampleModel